<template>
	<!-- 服药报告 -->
	<view class="report">
		<view class="fixed">
			<text @click="JI_LU">服药记录</text>
		</view>
		<view class="list">
			<view> <text>姓名</text> <text>{{vuex_myinfo.name || ''}}</text> </view>
			<view>
				<text>性别</text>
				<view class="sex">
					<view @click="sexActive = 1">
						<block v-if="vuex_httpImageUrl">
							<image v-if="sexActive" class='seximg'
								:src="vuex_httpImageUrl+'static/common/sexcheck1.png'" mode="widthFix"></image>
							<image v-else class='seximg' :src="vuex_httpImageUrl+'static/common/sexcheck.png'"
								mode="widthFix"></image>
						</block>
						<text>男</text>
					</view>
					<view @click="sexActive = 0">
						<block v-if="vuex_httpImageUrl">
							<image v-if="sexActive" class='seximg' :src="vuex_httpImageUrl+'static/common/sexcheck.png'"
								mode="widthFix"></image>
							<image v-else class='seximg' :src="vuex_httpImageUrl+'static/common/sexcheck1.png'"
								mode="widthFix"></image>
						</block>
						<text>女</text>
					</view>
				</view>
			</view>
			<view> <text>出生日期</text> <text>{{vuex_myinfo.birthday || ''}}</text> </view>
			<view> <text>手机号码</text> <text>{{vuex_myinfo.mobile}}</text> </view>
			<view> <text>身高</text> <text>{{vuex_myinfo.height || ''}}</text> </view>
		</view>
		<view class="list">
			<view><text>用药名称</text><input type="text" placeholder="请输入用药名称" v-model="form.medication" /></view>
			<view><text>用药厂家</text><input type="text" placeholder="请输入用药厂家" v-model="form.manufacturers" /></view>
			<view><text>用药剂量</text><input type="text" placeholder="请输入用药剂量" v-model="form.dosage" /></view>
			<view><text>用药时间</text><input type="text" placeholder="请输入用药时间" v-model="form.medication_time" /></view>
		</view>
		<view class="submit" @click="C_submit">确定</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				sexActive:null,
				form:{
					medication:'',
					manufacturers:'',
					dosage:'',
					medication_time:'',
				}
			};
		},
		mounted() {
			this.sexActive = this.vuex_myinfo.gender
		},
		methods:{
			JI_LU(){
				uni.navigateTo({
					url:'./JI_LU/JI_LU'
				})
			},
			C_submit(){
				let {medication,manufacturers,dosage,medication_time} = this.form;
				if(!medication){this.$u.toast('请输入用药名称');return};
				if(!manufacturers){this.$u.toast('请输入用药厂家');return};
				if(!dosage){this.$u.toast('请输入用药剂量');return};
				if(!medication_time){this.$u.toast('请输入用药时间');return};
				
				this.$u.post('/appuser/add_medicine',{...this.form}).then(res=>{
					this.$u.toast(res.msg)
				})
			}
		}
	}
</script>

<style lang="scss">
	.report{
		.fixed{
			margin: 50rpx 0;
			text-align: right;
			text{
				color: #46ADFF;
				border:1px solid #46ADFF;
				padding: 10rpx 30rpx  10rpx 60rpx;
				margin-right: -10rpx;
				background-color: #FFFFFF;
				border-top-left-radius: 50rpx;
				border-bottom-left-radius: 50rpx;
			}
		}
		.submit{
			padding: 20rpx;
			text-align: center;
		}
	}
	.list {
		overflow: hidden;
		width: 95%;
		margin: 20rpx auto;
		border-radius: 20rpx;
		background-color: #FFFFFF;
		padding: 0 30rpx;
		box-sizing: border-box;
		input{
			text-align: right;
		}
		>view {
			display: flex;
			justify-content: space-between;
			padding: 40rpx 0;
			border-bottom: 1px solid rgba(0, 0, 0, .05);
	
			.sex {
				display: flex;
				align-items: center;
	
				>view {
					margin-left: 30rpx;
					display: flex;
					align-items: center;
	
					.seximg {
						width: 25rpx;
						height: 25rpx;
						margin-right: 10rpx;
					}
				}
			}
		}
	}
	
</style>
